package io.kiki.sba.registry.client.provider;

import io.kiki.sba.registry.client.api.ClientConfig;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class DefaultClientConfig implements ClientConfig {

    private String env;


    private String instanceId;

    private String ip;


    private String zone;

    private String registryEndpoint;


    private int registryEndpointPort;


    private String dataCenter;


    private String appName;


    private int connectTimeout;


    private int socketTimeout;


    private int invokeTimeout;


    private int recheckInterval;

    private int observerThreadCoreSize;


    private int observerThreadMaxSize;


    private int observerThreadQueueLength;


    private int observerCallbackTimeout;


    private int syncConfigRetryInterval;


    private String accessKey;


    private String secretKey;


    private String algorithm;


    private long authCacheInterval;


    private boolean eventBusEnable;

    /**
     * Instantiates a new Default registry client config.
     *
     * @param env                       the env
     * @param instanceId                the instance id
     * @param ip                        the ip
     * @param zone                      the zone
     * @param registryEndpoint          the registry endpoint
     * @param registryEndpointPort      the registry endpoint port
     * @param dataCenter                the data center
     * @param appName                   the app name
     * @param connectTimeout            the connect timeout
     * @param socketTimeout             the socket timeout
     * @param invokeTimeout             the invoke timeout
     * @param recheckInterval           the recheck interval
     * @param observerThreadCoreSize    the observer thread core size
     * @param observerThreadMaxSize     the observer thread max size
     * @param observerThreadQueueLength the observer thread queue length
     * @param observerCallbackTimeout   the observer callback timeout
     * @param syncConfigRetryInterval   the sync config retry interval
     * @param accessKey                 the access key
     * @param secretKey                 the secret key
     * @param algorithm                 the algorithm
     * @param authCacheInterval         the auth cache interval
     */
    public DefaultClientConfig(String env, String instanceId, String ip, String zone, String registryEndpoint, int registryEndpointPort, String dataCenter, String appName, int connectTimeout, int socketTimeout, int invokeTimeout, int recheckInterval, int observerThreadCoreSize, int observerThreadMaxSize, int observerThreadQueueLength, int observerCallbackTimeout, int syncConfigRetryInterval, String accessKey, String secretKey, String algorithm, long authCacheInterval, boolean eventBusEnable) {
        this.env = env;
        this.instanceId = instanceId;
        this.ip = ip;
        this.zone = zone;
        this.registryEndpoint = registryEndpoint;
        this.registryEndpointPort = registryEndpointPort;
        this.dataCenter = dataCenter;
        this.appName = appName;
        this.connectTimeout = connectTimeout;
        this.socketTimeout = socketTimeout;
        this.invokeTimeout = invokeTimeout;
        this.recheckInterval = recheckInterval;
        this.observerThreadCoreSize = observerThreadCoreSize;
        this.observerThreadMaxSize = observerThreadMaxSize;
        this.observerThreadQueueLength = observerThreadQueueLength;
        this.observerCallbackTimeout = observerCallbackTimeout;
        this.syncConfigRetryInterval = syncConfigRetryInterval;
        this.accessKey = accessKey;
        this.secretKey = secretKey;
        this.algorithm = algorithm;
        this.authCacheInterval = authCacheInterval;
        this.eventBusEnable = eventBusEnable;
    }


    @Override
    public String getEnv() {
        return env;
    }


    @Override
    public String getInstanceId() {
        return instanceId;
    }

    @Override
    public String getIp() {
        return ip;
    }


    @Override
    public String getZone() {
        return zone;
    }


    @Override
    public String getRegistryEndpoint() {
        return registryEndpoint;
    }


    @Override
    public int getRegistryEndpointPort() {
        return registryEndpointPort;
    }


    @Override
    public String getDataCenter() {
        return dataCenter;
    }


    @Override
    public String getAppName() {
        return appName;
    }

    @Override
    public int getConnectTimeout() {
        return connectTimeout;
    }


    @Override
    public int getSocketTimeout() {
        return socketTimeout;
    }


    @Override
    public int getInvokeTimeout() {
        return invokeTimeout;
    }


    @Override
    public int getRecheckInterval() {
        return recheckInterval;
    }


    @Override
    public int getObserverThreadCoreSize() {
        return observerThreadCoreSize;
    }


    @Override
    public int getObserverThreadMaxSize() {
        return observerThreadMaxSize;
    }

    @Override
    public int getObserverThreadQueueLength() {
        return observerThreadQueueLength;
    }


    @Override
    public int getObserverCallbackTimeout() {
        return observerCallbackTimeout;
    }


    @Override
    public int getSyncConfigRetryInterval() {
        return syncConfigRetryInterval;
    }


    @Override
    public String getAccessKey() {
        return accessKey;
    }


    @Override
    public String getSecretKey() {
        return secretKey;
    }


    @Override
    public String getAlgorithm() {
        return algorithm;
    }


    @Override
    public long getAuthCacheInterval() {
        return authCacheInterval;
    }


    @Override
    public boolean isEventBusEnable() {
        return eventBusEnable;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof DefaultClientConfig)) {
            return false;
        }

        DefaultClientConfig that = (DefaultClientConfig) o;

        if (registryEndpointPort != that.registryEndpointPort) {
            return false;
        }
        if (env != null ? !env.equals(that.env) : that.env != null) {
            return false;
        }
        if (instanceId != null ? !instanceId.equals(that.instanceId) : that.instanceId != null) {
            return false;
        }
        if (ip != null ? !ip.equals(that.ip) : that.ip != null) {
            return false;
        }
        if (zone != null ? !zone.equals(that.zone) : that.zone != null) {
            return false;
        }
        if (registryEndpoint != null ? !registryEndpoint.equals(that.registryEndpoint) : that.registryEndpoint != null) {
            return false;
        }
        if (dataCenter != null ? !dataCenter.equals(that.dataCenter) : that.dataCenter != null) {
            return false;
        }
        return appName != null ? appName.equals(that.appName) : that.appName == null;
    }


    @Override
    public int hashCode() {
        int result = env != null ? env.hashCode() : 0;
        result = 31 * result + (instanceId != null ? instanceId.hashCode() : 0);
        result = 31 * result + (ip != null ? ip.hashCode() : 0);
        result = 31 * result + (zone != null ? zone.hashCode() : 0);
        result = 31 * result + (registryEndpoint != null ? registryEndpoint.hashCode() : 0);
        result = 31 * result + registryEndpointPort;
        result = 31 * result + (dataCenter != null ? dataCenter.hashCode() : 0);
        result = 31 * result + (appName != null ? appName.hashCode() : 0);
        return result;
    }


}
